home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Snippets / QuickDraw / Imageer 1.0.0d3 / Documentsƒ / ReadMe - Imageer 1⁄2 next >
Encoding:
Text File  |  1996-02-16  |  12.0 KB  |  190 lines  |  [ttro/ttxt]

  1. Imageer - Image processor
  2.  
  3. Written by: Jason Hodges-Harris,  Developer Technical Support.
  4.  
  5.  
  6. What Imageer does
  7.  
  8. The current release of Imageer is a basic image manipulation application which is designed to show how both Color QuickDraw and QuickDraw GX can be integrated into a single application with each document window supporting either technology.
  9. Supported functions include:
  10.  
  11. •   Ability to load and display 8 and 24 bits/pixel uncompressed TIFF images in both Macintosh and PC formats (Big and little endian) as well as the standard PICT format image files.
  12.  
  13. •   Conversion between Color QuickDraw based images to QuickDraw GX based bitmap shapes on an individual window basis with
  14.      simultaneous display and manipulation of both imaging technologies.
  15.  
  16. •   Image mirroring in both x and y axis and rotation supported in both formats.
  17.  
  18. •     Image color component separation and inversion. For QuickDraw GX this currently only supports the RGB colorspace.
  19.  
  20. •   Direct manipulation of the image pixel data to perform basic filtering effects.
  21.  
  22.  
  23.  
  24. Color Quickdraw
  25.  
  26. •   The use of GWorlds to store offscreen both the converted TIFF and PICT image data.
  27.  
  28. •   Accessing a GWorld, locating the base address of its PixMapHandle structure and safely drawing directly into this area to create the representation of the TIFF file as it's read and  parsed from the file.
  29.  
  30. •   For Indexed and greyscale TIFF files, and associated ColorTableHandle is created and completed from the information supplied in the TIFF file during the file parse and is then attached to the image GWorld during the NewGWorld() function call.
  31.  
  32. •   Custom color search functions to manipulate the color information stored within the GWorld for direct bit depth images (thousands and millions of colors) and the direct manipulation of the GWorld's Color Table structure for index bit depth images (256, 16 ,4, and 2 colors) to produce brightness, contrast and the separate removal of the red, green and blue  color components.
  33.  
  34.  
  35. QuickDraw GX
  36.  
  37. •   The use of parent and child viewports to enable scrolling of the gxShape object within the content region of a visible window.
  38.  
  39. •   The use of the QDTranslator function to convert the Color QuickDraw image in the window requiring conversion into a gxShape object.
  40.  
  41. •   Extensive use of QuickDraw GX transformation operations to perform various ink and shape manipulations.
  42.  
  43.  
  44. Additional features demonstrated
  45.  
  46. •   During the initialization process, if the PowerPC native version of the application is launched, checks are made to determine if a system feature is available from a weak linked shared library as Gestalt() doesn't always provide the correct response. In this case it is used to test for the availability of the weak linked QuickDrawGXLib as the application can operate without QuickDrawGX, but QuickDraw GX  is required to access the full function set.
  47.  
  48. •   The implementation of the Dialog manager GetStdFilterProc() and SetDialogDefaultItem() functions to provide default alert and warning dialogs with highlighting of the default button. These functions are not documented within Inside Macintosh, but have been available since System 7.0 and are fully explained in the Technical Note "Toolbox - TB 37 - Pending Update Perils".
  49.  
  50. •   The use of the Temporary Items folder to store cache files for both Undo and Redo operations for Color QuickDraw based images.
  51.  
  52. •   Custom dialogs for both the Open and Save file operations, with dialog hook functions to support the additional dialog items and a file filter to only display only the desired file types.
  53.  
  54.  
  55. How to use and general information about the Imageer application
  56.  
  57. After launching the application, the menubar contains six titles:  File, Edit, Window, Filters, Effects and Model.    
  58. Most of the items within these menu titles are disabled and restrict the user to opening a file, changing the imaging model and quitting the application.
  59.  
  60.  
  61. Below is an outline of the functionality of the various menu items.
  62.  
  63.  
  64. File menu.
  65.  
  66. •   Open. This displays a StandardGetFile() dialog and if displays both standard Macintosh PICT files and TIFF files (note that currently only 8 and 24 bit/pixel images in either Mac of PC byte order are supported). After selection the file is loaded into a offscreen GWorld and is transferred into an open window.
  67.  
  68. •   Close. This closes any open windows, either an image document window or the status window displaying the image colors of the frontmost image document window.
  69.  
  70. •   Close All. This closes all open windows.
  71.  
  72. •   Save.  This item is currently not supported and is to be implemented in a later release.
  73.  
  74. •   Save As. If the frontmost window contains an image, then this allows the image to be saved as a 'PICT' file or if using the QuickDraw GX imaging model, as a QuickDraw GX 'qdgx' file.
  75.  
  76. •   Revert to saved. When selected this will reload in the saved version of the image file and thus acts a roll back facility removing all changes made to the image.
  77.  
  78. •   Quit. When selected closes any open windows performs memory disposal etc. and exits the application.
  79.  
  80.  
  81. Edit menu.
  82.  
  83. •   Undo.  After one of the Effects or Filter menu items have been selected and prior to the image being manipulated, a copy of the image is saved. The Can't Undo menu item changes to Undo to indicate that the last operation on the image can be reversed. Selection of the Undo menu item restores to saved image information and changes the menu to Redo, which if selected reverts the image back to the manipulated version.
  84.  
  85. All of the other menu items Cut Copy and Paste are disabled as the application does not currently support these operations.
  86.  
  87.  
  88. Window menu.
  89.  
  90. •   Show Image Colors. When this menu item is enabled and selected it displays the color information of the frontmost image window.
  91.  
  92. •   Underneath the separator line is a dynamic list of the image files currently loaded. This displays a tick mark against the currently active window and these item can be selected to switch between  all of the windows.
  93.  
  94.  
  95. Filters menu.
  96.  
  97. •   Smooth.    This filter is a low pass smoothing filter which blurs the current window's image. This filter only operates on 256 color greyscale and 24 bit images. 
  98. Note, if a 256 color image is filtered the results are unpredictable as the images color table entries are shell sorted into luminance order before the filter operation.
  99.  
  100. •   Edge Detection.    The action of this filter is to find points of high contrast between points in the image and enhance them. Therefore to produce useful  results with this operation, the image has to be relatively free of noise and with clean changes in color. This filter operates on both 256 color and 24 bits/pixel color images and produces non reversible, false color results.
  101.  
  102.  
  103. Effects menu
  104.  
  105. •   Invert.   This operation  reverses the color component values for the current image window i.e. black to white and blue to yellow. As this operation is non destructive, by selecting this operation twice the identity operation is performed.
  106.  
  107. •   Brightness.   This operation lightens or darkens the color components of the current image window. If selected for a QuickDraw GX based object, the operation is non destructive as it affects the gxShape's ink transform mapping and does not alter the actual bitmap.
  108.  
  109. •   Contrast.   Similar operation to brightness except this enhances the range and saturation of displayed color.
  110.  
  111. •   Remove Color.   This selectively removes color components from the image in the current image window. This is selected by a sub menu containing the three primary color components Red, Green and Blue. If the image is displayed by Color QuickDraw the removal of one or more components is destructive, however this has been implemented in QuickDraw GX via an ink transformation and therefore is reversible.
  112.  
  113. •   Mirror X axis.
  114. •   Mirror Y axis.   Both of the Mirror operations function in a similar method taking the mid point of the image as the mirror along the axis and both the Color QuickDraw and QuickDraw GX methods produce visibly similar results. The difference is that the QD GX functions are gxShape transformations and the Color QuickDraw requires more effort to physically copy the image data line by line via a buffer using BlockMoveData() performing  any mapping operation as required.
  115.  
  116. •   Rotate 180°.        Does what it says to the current image window's image. Again this uses BlockMoveData() to perform the rotation in Color QuickDraw and in QuickDraw GX the function operates on a  gxShape with transformation set by GXRotateTransform().
  117.  
  118.  
  119. Model  menu
  120.  
  121. •   Use QuickDraw GX/ Use Color QuickDraw.   This menu item is updated dynamically when an image window is selected to display the drawing mode in operation for that window. Currently When a PICT or TIFF file is opened Color QuickDraw is used by default and thus this menu item displays "Use QuickDraw GX". When selected it calls a routine to convert the Color QuickDraw image into a gxShape and then alters the menu item to display "Use Color QuickDraw" for that window. 
  122.  
  123.  
  124. Building the application
  125.  
  126. "Imageer" is provided with project files and make scripts for 68k and Power PC native version in the following environments:
  127.  
  128. MPW ETO#19 Latest.                 - 68k, PPC and Fat binary makefiles using SC and MrC.
  129. Symantec C++ 8.0.x.                 - 68k project for Think C 7.x and PPC project for SPM 8.0.x.
  130. Metrowerks CodeWarrior 7.      - 68k and PPC projects.
  131.  
  132. To Build the application with a clean installation MPW 19.
  133.  
  134. Note, to link the application in Think C a cut down ToolLibs.o library was created in MPW containing only the object code for the related functions and has been renamed and included in the project folder as SmlToolLib.o together with the vocabulary file for Think's parser.
  135.  
  136. Application Files
  137.  
  138. doevent.c
  139.  
  140. •   Handles the processing of application events.
  141.  
  142. eventloop.c
  143.  
  144. •   Performs the program's wait next event loop.
  145.  
  146. fileCache.c
  147.  
  148. •   These functions perform the caching of Color QuickDraw based PixMap and Color Table information to temporary files located in the Temporary Items folder on the System Disk. They handle the creation, saving, loading and deletion of the cache files on a image window per set of Undo and Redo files basis.
  149.  
  150.  
  151. fileio.c
  152.  
  153. •   Contains the functions to load and parse a TIFF image file into a GWorld and the functions for loading and saving a PICT image file.
  154.  
  155. gxGraphics.c
  156.  
  157. •   Contains all of the QuickDraw GX specific code functions to handle the viewport creation and updates, the conversion of Color QuickDraw images into GX and the manipulation of the converted image data.
  158.  
  159. imageFilter.c
  160.  
  161. •   The functions held in this file perform (except for the custom color searches) the low down unsupported functions to perform the manipulation operations (filters, rotation etc.) on the Color QuickDraw images. 
  162.  
  163. menu.c
  164. •   Handles the processing of the menu options. This includes initialization, calling application functions to perform the selected options and enabling/disabling menu items.
  165.  
  166. offscrnGraphics.c
  167.  
  168. •   These functions are used with the Color QuickDraw imaging model to create offscreen graphics environments to hold the image information and to perform the transfer of images to the windows. It also contains functions to update and draw the color information into the Image Colors window.
  169.  
  170. start.cp
  171. •   Performs the initialization of the application setting the default values for the global variables, initializing the toolbox managers, testing for the availability of QuickDRaw GX and calling the main application loop.
  172.  
  173. windows.cp
  174. •   This performs the functions relating to opening, dragging, scrolling, closing and updating of the windows and also the display of the generic alert dialogs.
  175.  
  176. Imageer.r
  177. •   Contains information to specific to the MPW makefiles to enable the Rez tool to append the Imageer.rsrc file.
  178.  
  179. Imageer.rsrc
  180. •   This file contains the application resources.
  181.  
  182. Imageer.app.h
  183. •   The application's constants and window document structure are defined within this file.
  184.  
  185. Imageer.protos.h
  186. •   The application's function prototypes for all of the source code .c files are defined within this file and in alphabetical order of the source code files.
  187.  
  188.  
  189. Jason Hodges-Harris, December 1995.
  190. ©Apple Computer inc 1995. All rights reserved.